package com.tron.sync.service;

import com.tron.sync.entities.SyndaUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class SyndaUserServiceImpl  implements SyndaUserService{

    @Autowired
    JdbcTemplate jdbcTemplate;

    @Override
    public List<SyndaUser> findByTime(Date date) {
        final List<SyndaUser> users = jdbcTemplate.query("SELECT ipo.F_TYPE as orgType,ipo.NAME_ as orgName, ipu.ID_ as id,ipu.NAME_ as name ,ipu.GENDER_ as gender,ipu.STATUS_ as status,ipu.MOBILE_ as mobile,ipu.F_TELEPHONE as telephone,ipu.F_INSIDE_PHONE as insidePhone,ipu.F_JOB as job,ipu.F_RANK as jobRank,ipu.F_USER_NUMBER as userNumber,ipu.F_CATEGORY as category,ipu.F_TYPE as type,ipu.F_PINYIN as pinyin,ipu.GROUP_ID_ as groupId,ipu.F_HIREDATE as hireDate,ipu.F_JOIN_PARTY_DATE as joinPartyDate,ipu.F_SORT as sort,ipu.F_USER_IDENTITY as userIdentity,ipe.PATH_ as path   FROM ibps_party_employee ipu LEFT JOIN ibps_party_entity ipe ON ipu.GROUP_ID_ = ipe.ID_ LEFT JOIN ibps_party_org ipo ON ipu.GROUP_ID_ = ipo.ID_ WHERE ipu.CREATE_TIME_ > ? OR ipu.UPDATE_TIME_ > ?",
                new BeanPropertyRowMapper<>(SyndaUser.class),
                date,date);
        return users;
    }

}
